#include "threadPool.h"

void calc(int x, int y)
{
    int z = x + y;
    cout << "z = " << z << endl;
    this_thread::sleep_for(chrono::seconds(2));
}

int calc1(int x, int y)
{
    int z = x + y;
    this_thread::sleep_for(chrono::seconds(10));
    return z;
}

int main()
{
    ThreadPool pool;
    vector<future<int>> results;
    for (int i = 0; i < 10; i++)
    {
        // auto obj = bind(calc, i, i * 2);
        results.emplace_back(pool.addTask(calc1, i, i * 2));
    }
    for (auto &item : results)
    {
        cout << "result " << item.get() << endl;
    }
    return 0;
}